<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div{
            width: 300px;background-color: rgba(0,0,0,0.3);
            padding: 10px;
            position: relative;/*做参照物*/
        }
        input{
            border: 0;padding: 10px 20px;width: 260px;
        }
        p{margin: 0;color: red;font-size: 12px;}
        img{
            position: absolute;
            right: 40px;
            top: 14px;
        }

    </style>
</head>
<body>
<div>
  <input type="text" placeholder="请输入用户名">
  <p>用户名不能为空!</p>
  <img src="img.png">
</div>
</body>
</html>